<?php


namespace App\Http\Controllers\Admin;


use App\Http\Controllers\Controller;
use App\Model\Admins;
use App\Model\Users;
use Illuminate\Http\Request;

class LoginController extends Controller
{
    public function register(Request $request){
        if ($request->isMethod('post')){
            $data = $request->post();
            $register = new Users();
            $result = $register->register($data);
            return JsonResponse(200,$result['success'],$result['msg']);
        }else{
            return JsonResponse(3001,false,'非法请求');
        }

    }

    /**
     * 用户登录
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function login(Request $request){
        if ($request->isMethod('post')){
            $data = $request->post();
            $admin = new Admins();
            $result = $admin->login($data);
            return JsonResponse($result['code'],$result['success'],$result['msg'],$result['user']);
        }else{
            return JsonResponse(3001,false,'非法请求');
        }
    }
}
